using System;
using UniversalAdminSystem.Domian.Core;
using UniversalAdminSystem.Domian.SystemSettings.ValueObjects;

namespace UniversalAdminSystem.Domian.SystemSettings.Aggregates;

public class SystemSetting : AggregateRoot
{
    public Guid Id { get; private set; }
    public SettingKey Key { get; private set; } = null!;
    public SettingValue Value { get; private set; } = null!;
    public SettingDescription? Description { get; private set; }
    public string? Group { get; private set; }
    public DateTime CreateTime { get; private set; }
    public DateTime UpdateTime { get; private set; }

    private SystemSetting() { }
    public static SystemSetting Create(SettingKey key, SettingValue value, SettingDescription? description = null, string? group = null)
    {
        return new SystemSetting
        {
            Id = Guid.NewGuid(),
            Key = key,
            Value = value,
            Description = description,
            Group = group,
            CreateTime = DateTime.UtcNow,
            UpdateTime = DateTime.UtcNow
        };
    }
    public void UpdateValue(SettingValue value)
    {
        Value = value;
        UpdateTime = DateTime.UtcNow;
    }
} 